using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class P_SpriteLoop : MonoBehaviour
{
    public Sprite[] sprites;
    private void OnEnable()
    {
        StartCoroutine(Loop());
    }
    private IEnumerator Loop()
    {
        while (true)
        {
            for (int i = 0; i < sprites.Length; i++)
            {
                GetComponent<Image>().sprite = sprites[i];
                yield return new WaitForSeconds(0.15f);
            }
        }
    }
    private void OnDisable()
    {
        StopAllCoroutines(); 
    }
}
